﻿
<style type="text/css">
    .topSpan{
        border: lightskyblue 1px solid; 
        color: rgb(31, 159, 255); 
        padding: 5px;
    }
                                                                          
</style>
@{
    var dic = (Dictionary<int, Dictionary<string, string>>) ViewBag.text2;
    var tf = dic.Values.Count(a => a.Values.First() == "2");
    var sg = dic.Values.Count(a => a.Values.First() == "1");
    var bl = dic.Values.Count(a => a.Values.First() == "3");
    <br />
    <div>
        <span class="topSpan">判断题 @tf</span>
        <span class="topSpan">单选题 @sg</span>
        <span class="topSpan">填空题 @bl</span>
    </div>
    <br/>
    int i = 0;
    string[] strArray = { "1", "2" };
    foreach (var temp in dic)
    {
        <span>
            <span>
                @(i + 1)、
                @switch (temp.Value["type"])
                {
                    case "1":
                        <label>单选题</label>
                        break;
                    case "2":
                        <label>判断题</label>
                        break;
                    case "3":
                        <label>填空题</label>
                        break;
                }
                &nbsp;分值&nbsp;@temp.Value["score"]&nbsp;
            </span>
            <!--给判断题的位置↓-->
            @if (strArray.Contains(temp.Value["type"]))
            {
                <span style="color: red">正确答案&emsp;@temp.Value["correct"]</span>
            }
            @if (temp.Value["keyWords"] != "")
            {
                <span>&emsp;关键词:</span>
                <span style="color: rgb(31, 159, 255);font-weight:600">@temp.Value["keyWords"]</span>
            }
        </span>
        <br />
        switch (temp.Value["type"])
        {
            case "2":
                <span>@temp.Value["quest"]</span>
                <br />
                <span><input type="radio" name=@i />&nbsp;对</span>
                <br />
                <span><input type="radio" name=@i />&nbsp;错</span>
                i++;
                <br />
                <br />
                break;
            case "1":
                <span>@temp.Value["quest"]</span>
                var alphabet = 'A';
                //减6是因为除了选项其它就已经占了6个,剩下就是选项的数目
                for (var k = 1; k <= temp.Value.Count - 6; k++)
                {
                    <p><input type="radio" name=@i />@alphabet. @temp.Value["option" + k]</p>
                    alphabet = Convert.ToChar(alphabet + 1);
                }
                if (!temp.Value["analysis"].Equals(""))
                {
                    @temp.Value["analysis"]
                }
                i++;
                <br />
                <br />
                break;
            case "3":
                <span>@temp.Value["quest"]</span>
                <span style="color: red">
                    正确答案 &emsp; @temp.Value["blanks"]
                </span>
                <br />
                <br />
                i++;
                break;
        }
    }
}








@* 不能直接用
    else if (temp.Value["type"] == "多选题")
            {
                @temp.Value["quest"]
                for (int k = 4; k < temp.Value.Count - 1; k++)
                {
                    <p><input type="radio" name=@i/> @temp.Value["option" + (k - 3)]</p>
                }
        i++;
            }*@
@*else if (temp.Value["type"] == "不定项题")
    {
        @temp.Value["quest"]
                for (int k = 4; k < temp.Value.Count; k++)
        {
                    <p><input type="radio" name=@i/> @temp.Value["option" + (k - 3)]</p>
                }
        i++;
    }*@
@*else if (temp.Value["type"] == "简答题")
    {
        @temp.Value["quest"]
                i++;
    }*@
